#include <iostream>
#include <list>
using namespace std;
void test(){
    list<int>list={1,2,3};
    //插入元素
    list.push_back(4);
    list.push_front(0);
    list.insert(list.end(),5);
    for(auto it=list.begin();it!=list.end();++it){
        cout<<*it<<"    ";
    }
    cout<<endl;
    //删除元素
    list.pop_back();
    auto it=list.end();
    --it;
    --it;
    list.erase(it);
    for(auto it=list.begin();it!=list.end();++it){
        cout<<*it<<"    ";
    }
    cout<<endl;
    //查找修改元素
    *list.begin()=10;
    //链表的迭代器是双向迭代器，是不支持随机访问的

    for(auto it=list.begin();it!=list.end();++it){
        cout<<*it<<"    ";
    }
    cout<<endl;
}

int main(int argc, char * argv[]){
    test();    
    return 0;
}

